package eoeProject.edenOfEast.page.archives.archivesTop;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.WebPage;

import eoeProject.edenOfEast.core.EOEAuthenticatedWebSession;
import eoeProject.edenOfEast.page.analyses.analysesTop.component.AnalysesTopPanel;
import eoeProject.edenOfEast.page.archives.archivesTop.component.ArchivesTopPanel;
import eoeProject.edenOfEast.page.topPage.component.TopPanel;

@AuthorizeInstantiation({"ADMIN","USER"})
public class Index extends WebPage {
	private static final long serialVersionUID = 1L;

	private BookmarkablePageLink<WebPage> linkToTop = new BookmarkablePageLink<WebPage>("linkToTop",eoeProject.edenOfEast.page.topPage.Index.class);
	private BookmarkablePageLink<WebPage> linkToTactics = new BookmarkablePageLink<WebPage>("linkToTactics",eoeProject.edenOfEast.page.tactics.tacticsTop.Index.class);
	private BookmarkablePageLink<WebPage> linkToAnalyses = new BookmarkablePageLink<WebPage>("linkToAnalyses",eoeProject.edenOfEast.page.analyses.analysesTop.Index.class);
	private BookmarkablePageLink<WebPage> linkToArchives = new BookmarkablePageLink<WebPage>("linkToArchives",eoeProject.edenOfEast.page.archives.archivesTop.Index.class);
	private BookmarkablePageLink<WebPage> linkToLogin = new BookmarkablePageLink<WebPage>("linkToLoginOrLogout",eoeProject.edenOfEast.page.loginPage.Index.class);
	private BookmarkablePageLink<WebPage> linkToLogout = new BookmarkablePageLink<WebPage>("linkToLoginOrLogout",eoeProject.edenOfEast.page.logoutPage.Index.class);

    public Index() {
    	//DB db = new DB();
		add(new ArchivesTopPanel("archivesTopPanel").setOutputMarkupId(true));
	    if(EOEAuthenticatedWebSession.get().isSignedIn()){
	    	linkToLogout.add(new Label("linkToLoginOrLogoutLabel" ,"ログアウト"));
	    	add(linkToLogout.setOutputMarkupId(true));
	    }
	    else{
	    	linkToLogin.add(new Label("linkToLoginOrLogoutLabel" ,"ログイン"));
	    	add(linkToLogin.setOutputMarkupId(true));
	    }
	    add(linkToTop.setOutputMarkupId(true));
	    add(linkToTactics.setOutputMarkupId(true));
	    add(linkToAnalyses.setOutputMarkupId(true));
	    add(linkToArchives.setOutputMarkupId(true));
    }
}